initrds created with mkinitramfs, mkinitrd, yaird or any other
tool can sometime contain errors that make your system un-bootable,
or that output error during the boot process. It is usually a pain
to debug those errors, as... you often don't have a shell, needed
softwares are missing from the initrd, ...
Generally, there are two approaches that can be easily used to
debug an initrd:
uncompress the initrd, and have a peek in the scripts to see
what's being done and what it is doing when the init process
stops (and why) - always works.
at boot time, have the initrd output some debugging lines, or
get a prompt to try to manually understand what's going wrong
or why the commands are failing. Using this method requires support
from the tool used to create the initrd, so it won't be discussed
in this note.
So, to access the content of an initrd, you need to run a few commands
depending on the format of the initrd itself. Nowdays, most initrds
are either gzip-compressed cpio files, cramfs or other more or less
esotheric file systems. You can start with something like:
% file -Ls /boot/initrd.img
|
|
If you are lucky, it will be a cramfs:
/boot/initrd.img-2.6.8-3-686-smp: Linux Compressed ROM File System data, [...]
|
|
just mount it with something like:
% mount -o loop /boot/initrd.img /mnt/whatever
|
|
If you are a bit less lucky, it will be gzip compressed:
/boot/initrd.img: gzip compressed data, from Unix,
|
|
Start by just uncompressing it:
% gzip -cd < /boot/initrd.img > /tmp/initrd.uncompressed
|
|
Repeat the "file" command above against /tmp/initrd.uncompressed.
If you are lucky, again, it will be a filesystem. Just mount it with
the same "mount -o loop..." as above. If you are a bit less lucky,
you will see something like:
$ file -sL /tmp/initrd.uncompressed
/tmp/initrd.uncompressed: ASCII cpio archive (SVR4 with no CRC)
|
|
which means that the initrd is a simple cpio archive. Uncompress it
with something like:
$ cpio --extract --make-directories < /tmp/initrd.uncompressed
|
|
Now, you can start your debugging by either looking into /linuxrc,
/init, or /sbin/init. You can obviously modify the filesystem, and
reverse the steps to create a new initrd to test. Good luck!